//
//  WJFontListTopView.swift
//  PDFSign
//
//  Created by 李永彬 on 2025/9/27.
//

import UIKit

class WJFontListTopView: UIView {
    
    private lazy var nameLabel: UILabel = {
        let label = UILabel()
        label.textAlignment = .left
        label.font = UIFont.montserratMedium(16)
        label.textColor = UIColor(hex: "#000000")
        label.text = "Enter your name"
        return label
    }()
    
    lazy var textField: UITextField = {
        let field = UITextField()
        field.textAlignment = .left
        field.font = UIFont.montserratMedium(16)
        field.textColor = UIColor(hex: "#000000", alpha: 0.6)
        field.placeholder = "Enter your name"
        field.backgroundColor = UIColor(hex: "#FFFFFF")
        field.layer.masksToBounds = false
        field.layer.cornerRadius = 12
        field.delegate = self
        return field
    }()

    override init(frame: CGRect) {
        super.init(frame: frame)
        self.backgroundColor = UIColor(hex: "#121212", alpha: 0.05)
        layer.cornerRadius = 24
        layer.borderColor = UIColor(hex: "#FFFFFF").cgColor
        layer.borderWidth  = 0.5
        layer.shadowColor = UIColor.white.cgColor
        layer.shadowOffset = CGSize(width: 0, height: 0)
        layer.shadowOpacity = 0.7
        layer.shadowRadius = 3.0
        layer.masksToBounds = false
        commonInitSubviews()
    }
    
    func commonInitSubviews() {
        addSubview(nameLabel)
        addSubview(textField)
        nameLabel.snp.makeConstraints { make in
            make.top.equalToSuperview().offset(12)
            make.height.equalTo(20)
            make.leading.trailing.equalToSuperview().inset(12)
        }
        
        textField.snp.makeConstraints { make in
            make.top.equalTo(nameLabel.snp.bottom).offset(10)
            make.leading.trailing.equalToSuperview().inset(12)
            make.height.equalTo(48)
        }
    }
    
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

extension WJFontListTopView: UITextFieldDelegate {
    func textFieldShouldReturn(_ textField: UITextField) -> Bool {
        endEditing(true)
    }
}
